<?php
/**
 * Description of KeywordController
 *
 * @author zxcms
 */
class Cms_KeywordController extends H_Controller_Cms_Action {
    public function indexAction(){
        
        $kwOb = new H_Keyword();
        $key = $this->_request->getParam('key', -1);
        if ($key != -1){
            $data = $kwOb->find($key);
            $this->view->item = $data[0];
            $this->view->act = H_G::EDIT;
        }else{
            $this->view->act = H_G::ADD;
        }
        if($this->_request->isPost()){
            $data = $this->_request->getParams();
            if ($data['act'] == H_G::ADD)
                $kwOb->add($data);
            else                
                $kwOb->edit($data['keyword'], $data);
            $this->_redirect($this->_request->getRequestUri());
        }        
        $this->view->list = $kwOb->fetchAll();
    }
    public function delAction(){
        $kwOb = new H_Keyword();
        $key = $this->_request->getParam('key', -1);
        $kwOb->del($key);
        $this->_redirect("/cms/keyword");
    }
  
    public function getlistforallpageAction(){
        $kwOb = new H_Keyword();
        $controller = $this->_request->getParam('cController');
        $action = $this->_request->getParam('cAction');
        $this->view->keyword = $this->_request->getParam('keyword');
        
        $this->view->list = $kwOb->getKeyByControllerAndAction($controller, $action);
    }
}
?>
